/*************************************************************************
> File Name: 03_test.cpp
> Author: hzy
> Created Time: 2023-08-14 15:45:43
> Description:  同名成员函数的重载
************************************************************************/
#include <iostream>

using namespace std;

class Base
{
public:
     void func1()
    {
        cout << "Base::void func1()" << endl;
    }
    void func1(int num)
    {
        cout << "Base::void func1(int num)" << endl;
    }
    void myfunc()
    {
        cout << "Base::void myfunc()" << endl;
    }
};

class Son1 : public Base
{
public:
    void func1()
    {
        cout << "Son1::void func1()" << endl;
    }
};

class Son2 : public Base
{
public:
    void func1(int num1, int num2)
    {
        cout << "Son2::void fun1(int num1,int num2)" << endl;
    }
};

class Son3 : public Base
{
public:
    int func1(int num)
    {
        cout << "Son3::int fun1(int num)" << endl;
        return 0;
    }
};

int main()
{
    Son1 son1;
    son1.func1();
    son1.Base::func1();   //通过类域去访问基类的同名函数
    son1.Base::func1(20);
    // son1.func1(11);   //重载func1之后，基类的同名函数被隐藏
    son1.myfunc();
    cout << "=========" << endl;

    Son2 son2;
    son2.func1(22, 22); // 重载func1之后，基类的同名函数被隐藏
    son2.myfunc();
    cout << "=========" << endl;

    Son3 son3;
    // son3.func1()      //重载func1之后，基类的同名函数被隐藏
    son3.func1(33);
    son3.myfunc();

    return 0;
}